/**
 *	部门管理控制层
 */
 
 Ext.define("AM.controller.DeptController" ,{
 	extend  : 'Ext.app.Controller',
 	alias   : 'widget.deptcontroller',
 	init    : function() {
 		this.control({
 			'deptlist' : {
 				itemclick : function(tree, record, item, e, opti) {
 					record.collapse(function() {
 						return true;
 					}, function(node) {
 						console.log(node);
 					})
 				}
 			},
 			'deptlist button[id=update]' : {
 				click : function(b) {
 					var grid = b.findParentByType('deptlist');
 					var tree = Ext.getCmp('dept-tree');
 					Ext.create('AM.util.GridDoActionUtil').doSave(grid, tree);
 				}
 			},
 			'deptlist button[id=add]' : {
 				click : function(b) {
 					
 					var grid = b.findParentByType('deptlist');
 					var modelObj = {
 						text : '',
 						id   : '01',
 						info : '',
 						leaf : true,
 						manager    : '',
 						nodeType   :'ROOT',
 						orderIndex : 0
 					}
 					
 					var tree = Ext.getCmp('dept-tree');//获取左边树组件
 					Ext.create('AM.util.GridDoActionUtil').doInsert(grid, modelObj, tree);
 				}
 			}
 		})
 	},
 	views   : [
 		'DeptTree',
 		'DeptList',
 		'MainLayout'
 	],
 	stores  : [
 		'DeptStore4Tree',
 		'DeptStore'
 	],
 	models  : [
 		//'DeptModel'
 		'ModelFactory'
 	]
 });